package storage

import "time"

// StorageType 缓存实例类型
//   - 0 => 未知或无效的驱动库
//   - 1 => MemoryCache 缓存实例
//   - 2 => RedisCache 缓存实例
//   - 3 => L2Cache Local+Remote 二级缓存实例, 通常为 MemoryCache + RedisCache 驱动组合模式
type StorageType uint8

const (
	StorageInvalid StorageType = iota // 0 => 未知或无效的缓存实例
	StorageMemory                     // 1 => MemoryCache 缓存实例
	StorageRedis                      // 2 => RedisCache 缓存实例
	StorageL2Cache                    // 3 => L2Cache Local+Remote 二级缓存实例, 通常为 MemoryCache + RedisCache 驱动组合模式
)

func (t StorageType) String() string {
	switch t {
	case StorageMemory:
		return "Storage Memory"
	case StorageRedis:
		return "Storage Redis"
	case StorageL2Cache:
		return "Storage L2Cache"
	default:
		return "Storage Invalid"
	}
}

// LiveState 缓存实例的运行状态枚举值
//   - 0 => 关闭状态
//   - 1 => 正常状态
//   - 2 => 异常状态
type LiveState int8

const (
	LiveStateShutdown LiveState = iota // 0 关闭状态
	LiveStateNormal                    // 1 正常状态
	LiveStateFailure                   // 2 异常状态
)

type TypeBase interface {
	string | bool | TypeNumber | TypeTime
}
type TypeBaseSlice interface {
	[]string | []bool |
		[]int | []int8 | []int16 | []int32 | []int64 |
		[]uint | []uint8 | []uint16 | []uint32 | []uint64 |
		[]float32 | []float64 |
		[]time.Time | []time.Duration | []time.Month | []time.Weekday
}
type TypeNumber interface {
	TypeInt | TypeUint | TypeFloat
}
type TypeInt interface {
	int | int8 | int16 | int32 | int64 // rune => int32
}
type TypeUint interface {
	uint | uint8 | uint16 | uint32 | uint64 // byte => uint8  uintptr => uint32/uint64
}
type TypeFloat interface {
	float32 | float64
}
type TypeTime interface {
	time.Time | time.Duration | time.Month | time.Weekday
}
type TypeSliceAny []any
type TypeSliceBase[T TypeBase] []T
type TypeMapBaseAny[K TypeBase] map[K]any
type TypeMapComparableAny[K comparable] map[K]any
type TypeMapBaseAs[K TypeBase, V TypeBase] map[K]V
